package thread;

public class TestDemo18 {
    private static Object object = new Object();
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            // 进行 wait
            synchronized (object){
                System.out.println("wait 前");
                try {
                    object.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("wait 后");
            }
        });
        t1.start();

        Thread t2 = new Thread(() -> {
            // 进行 notify
            synchronized (object){
                System.out.println("notify 前");
                object.notify();
                System.out.println("notify 后");
            }
        });
        // 3s 后，通知 t1线程继续执行
        Thread.sleep(3000);
        t2.start();
    }
}
